Repository navigation
docs: a local's initial value can keep a constant out of its own register - #485
Merged
Merged
Conversation
…gister of its own Two paragraphs in msvc-backend.md after "A defect class: which constant gets the callee-saved register", from openBuildingStatusMenuForBuildingID (0x00463310, sourcehold#484). With menuTab initialised to 1, the original's push esi was our push 1. With no initial value and the 1 assigned only in the one arm that relied on it, the probe lists one candidate more, a temp that also gets esi where menuTab is not live, and the push uses it. The paragraphs say that assigning it early was worse, how to check that every path still assigns the local (/w14701), how this differs from the section's "no source handle" (it changes which candidates exist, not how a value is spelled), and that it rests on one function so far. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gynt
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The section "A defect class: which constant gets the callee-saved register" of
tools/compiler-internals/msvc-backend.mdends by saying that the allocator's choice of what to keep in a callee-saved register has no source handle. #484 found a source form that decides whether a constant gets a register of its own. This PR adds it to the end of that section as two paragraphs.The case. In
AlphaAndButtonSurface::openBuildingStatusMenuForBuildingID(0x00463310), the original pushesesi, which holds 1, as the second argument ofextendResourceCountdownForPlayerBuildingsOfType(thepush esiat 0x004633BD). The draft pushed the immediate 1, which left it one instruction off. The draft gave the localmenuTab = 1as its initial value, and in the second switch the barracks' arm was the one arm that relied on it. These all still gavepush 1: the argument written asmenuTab,TRUE,1uor(dword)1, aninttab, and two definitions of it. Assigning the 1 in both arms of the owner test was worse (quick_diff 0.9929 against 0.9964). With no initial value and the 1 assigned in the barracks' arm, the push usesesiand the function is at 100% (#484).What
reg_scores.pyshows.menuTabhas the function's highest+0x0ckey (175, and 176 after the change) and getsesiin both texts. After the change the probe lists one candidate more: an unnamed(temp)that also getsesiwheremenuTabis not live yet. By where it sits it is the constant 1. The probe cannot name it, and the paragraph says so.What changes
updateAIPlayerStateone gives the case, with the numbers above./w14701to see that every path still assigns the local (C4701 stays quiet). It says that the section's finding is about spellings of the same value, which this lever is not, and that the lever rests on one function so far.Documentation only: no game source, header or build file changes, so no function's match percentage can move.
Other PRs. #481, #366 and #396 also change
msvc-backend.md, in other places.git merge-treemerges each of them with this branch; #396 conflicts incmake/compiler-flags-gl.txt, as it already does with main. #418 bringsupdateAIPlayerStateitself to 100% with a source change (two more stores of 0), so the section's "no source handle" will need a correction once #418 is in. This PR leaves that sentence as it is.🤖 Generated with Claude Code